package com.xuxu.product.controller;

import com.xuxu.common.utils.R;
import com.xuxu.product.service.OrderService;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;

/**
 * @className: OrderController
 * @author: Maxuxu
 * @date: 2022/9/2 15:22
 * @description: 订单控制类
 */
@RestController
@RequestMapping("/product/order")
@Api(value = "orderController",tags = "订单管理")
public class OrderController {
    @Resource
    private OrderService orderService;

    /**
     * 查询指定id的订单信息
     * @param id
     * @return
     */
    @GetMapping("/getOneOrder/{id}")
    public R getOrderByid(@PathVariable("id") Integer id){
        return orderService.getOrderById(id);
    }

    /**
     * 查询所有的订单信息
     * @return
     */
    @GetMapping("/getAllOrder")
    public R getAllOrder(){
        return orderService.getAllOrder();
    }

    @GetMapping("/getOrderByPage/{currentPage}/{pageSize}")
    public R getOrderByPage(@PathVariable("currentPage") Integer currentPage,
                            @PathVariable("pageSize") Integer pageSize) {
        return orderService.SelectBypage(currentPage,pageSize);
    }

}
